
function [subfields, myvalues, namesant] = nextlevel(mystruct, myvalues, names2) 
    namesant=names2;
    if iscell(mystruct)==0
    names=fieldnames(mystruct);
    names2=names;
    
    for i=1:size(names,1)
       subfields=getfield(mystruct, names{i});    
       if isstruct(subfields) 
       for a=1:size(subfields,2)
       [subfields, myvalues, namesant]=nextlevel(subfields, myvalues, names2);

       end
       
       elseif iscell(subfields)
       subfields2=subfields;
       for c=1:size(subfields2,2)
       [subfields, myvalues, namesant]=nextlevel(subfields2{1, c}, myvalues, names2);
       end
       
       elseif iscell(subfields)==0
        [a , b] = size(myvalues);
        myvalues{1, b+1}=subfields;
        myvalues{2, b+1}=namesant{1, 1};
        
        for b=1:size(namesant, 1)-1
            namesant{b, 1}=namesant{b+1, 1};
        end
       end
       names2=namesant;
    end  
    end
